
const router = require('koa-router')(),
  user=require('../models/user.js');


router.prefix('/user')

router.get('/change', async function (ctx, next) {
    const {id,name,sex,brief,birthday,phone}=ctx.query;
    ctx.body=await user.changeUserInfo(id,name,sex,brief,birthday,phone);
})

router.get('/interestme',async function(ctx,next){
  const {id}=ctx.query;
  ctx.body=await user.interestme(id);
})

router.get('/other',async function(ctx,next){
  const {id}=ctx.query;
  ctx.body=await user.getotherhome(id);
})

router.get('/add',async function(ctx,next){
  const {id,otherid,fanTime}=ctx.query;
  ctx.body=await user.addattention(id,otherid,fanTime);
})

router.get('/del',async function(ctx,next){
  const {id,otherid}=ctx.query;
  ctx.body=await user.delattention(id,otherid)
})

router.get('/check',async function(ctx,next){
  let {id,otherid}=ctx.query;
  if(otherid==undefined){
    otherid=id
  }
  if(id==undefined){
    id=otherid
  }
  ctx.body=await user.changeattention(id,otherid)
})

router.get('/getlike',async function(ctx,next){
  const {id}=ctx.query;
  ctx.body=await user.getLike(id)
})

router.get('/changepwd', async function (ctx, next) {
  const {id,cipher}=ctx.query;
  ctx.body=await user.changePwd(id,cipher);
})

router.get('/find',async function(ctx,next){
  const {name}=ctx.query;
  ctx.body=await user.findByName(name)
})

router.post('/upload',async function(ctx,next){
  let file=ctx.request.files.file
  ctx.body=await user.uploadpic(file);
})

router.get('/changehead',async function(ctx,next){
  let {id,path}=ctx.query
  ctx.body=await user.changehead(id,path)
})

router.get('/changebg',async function(ctx,next){
  let {id,path}=ctx.query
  ctx.body=await user.changebg(id,path)
})

router.get('/gethelp',async function(ctx,next){
  ctx.body=await user.getHelp()
})
module.exports = router
